package service_sys

import (
	"strconv"
	"strings"
	"wrblog-api-go/app/dao/dao_sys"
	"wrblog-api-go/app/model/model_sys"
	"wrblog-api-go/pkg/utils"
)

func GetSysUserPageList(sysUser model_sys.SelectSysUser) ([]model_sys.SysUserVo, int64, error) {
	return dao_sys.GetSysUserPageList(sysUser)
}

func GetSysUserById(userId int) (model_sys.SysUserVo, error) {
	return dao_sys.GetSysUserById(userId)
}

func AddSysUser(sysUser model_sys.SaveSysUser) (string, error) {
	sysUser.UserId = strconv.FormatInt(utils.NextId(), 10)
	sysUser.CreateTime = utils.NewTimeNow()
	return dao_sys.AddSysUser(sysUser)
}
func EditSysUser(sysUser model_sys.SaveSysUser) (int64, error) {
	sysUser.UpdateTime = utils.NewTimeNow()
	return dao_sys.EditSysUser(sysUser)
}

func RemoveSysUser(userIds string, uk string) (int64, error) {
	return dao_sys.RemoveSysUser(strings.Split(userIds, ","), uk)
}

func GetUserByUk(uk string) (model_sys.SysUserPo, error) {
	return dao_sys.GetUserByUk(uk)
}

func GetUserBySpaceUrl(spaceUrl string) (sysUser model_sys.SysUserPo, err error) {
	return dao_sys.GetUserBySpaceUrl(spaceUrl)
}

func GetUserByMk(mk string) (sysUser model_sys.SysUserPo, err error) {
	return dao_sys.GetUserByMk(mk)
}

func GetUserByMbk(mbk string) (model_sys.SysUserPo, error) {
	return dao_sys.GetUserByMbk(mbk)
}

func GetUserById(userId int64) (model_sys.SysUserVo, error) {
	return dao_sys.GetUserById(userId)
}
